<!doctype html>
<html>

	<head>
		<meta charset="utf-8">
		<meta http-equiv="X-UA-Compatible" content="IE=edge">
		<meta name="referrer" content="no-referrer">
		<meta http-equiv="Cache-Control" content="private">
		<meta content="telephone=no,email=no" name="format-detection">
		<meta content="yes" name="apple-mobile-web-app-capable">
		<meta http-equiv="Access-Control-Allow-Origin" content="*" />
		<meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
		<title>任务进行中</title>
					
		<link rel="stylesheet" href="./css/bootstrap/css/bootstrap.css">
		<link rel="stylesheet" href="./css/common/style.css">
		<script src="./js/lib/rem.js"></script>
		<script src="./js/lib/jquery-3.3.1.min.js"></script>
		
	</head>
	<style>
		.taskpage{width:100%;height:100%;position:fixed;background:#f3f3f3;}
		.taskpage-header{width:100%;height:1rem;line-height:1rem;text-align:center;background:#0c5dac;}
		.taskpage-header > span{font-size:0.34rem;color:#fff;}
		
		.taskpage-title{width:100%;height:4.2rem;background:#fff;display:flex;flex-direction:column;justify-content:flex-end;}
		.taskpage-img{width:100%;height:2rem;line-height:2rem;text-align:center;}
		.taskpage-img > img{width:1.8rem;height:1.8rem;}
		.taskpage-notice{width:85%;height:1.6rem;margin:0.2rem auto 0.3rem;background:#e8e8e8;border-radius:0.2rem;display:flex;flex-direction:column;justify-content:center;align-items:center;}
		.taskpage-notice > span{height:0.5rem;line-height:0.5rem;font-size:0.34rem;color:#333;font-weight:bold;}
		
		.taskpage-platform{width:100%;height:calc(100% - 5.2rem);padding-top:0.1rem;overflow:hidden;}
		.taskpage-platform-list{width:100%;height:calc(100% - 0.2rem);margin:0 auto 0.2rem;overflow:hidden;}
		.platform-wrap{padding-bottom:0.8rem;}
		.platform-item{width:100%;height:1.6rem;margin-bottom:0.1rem;border-bottom:0.02rem solid #ccc;display:flex;flex-direction:row;justify-content:space-around;}
		.platform-img{width:25%;height:1.6rem;line-height:1.6rem;text-align:center;}
		.platform-img > img{width:1.3rem;height:1.3rem;border-radius:0.1rem;}
		.platform-infor{width:65%;height:1.6rem;}
		.platform-title{width:100%;height:0.5rem;line-height:0.5rem;}
		.platform-title > span{font-size:0.3rem;color:#222;}
		.platform-descript{width:100%;height:1rem;overflow:hidden;}
		.platform-descript > p{width:100%;height:0.9rem;line-height:0.34rem;text-indent:1em;font-size:0.26rem;color:#999;margin:0 !important;}
		
		.loadover{width:100%;height:0.8rem;margin-top:0.2rem;text-align:center;}
		.loadover > span{color:#666;font-size:0.3rem;}
		
	</style>
	<body>
		<div class="taskpage">
			<div class="taskpage-header">
				<span>平台接入</span>
			</div>
			
			<div class="taskpage-title">
				<div class="taskpage-img">
					<img src="./img/executing.gif" alt="">
				</div>
				
				<div class="taskpage-notice">
					<span>api 接口与服务器连接成功</span>
					<span>请勿进行其它操作</span>
				</div>
			</div>

			<div class="taskpage-platform">
				<div class="taskpage-platform-list">
					<div class="platform-wrap" id="platformInfor">
						
					</div>
				</div>
								
			</div>
			
		</div>
		
		<!-- private and protocol select state -->
		<div class="state-modal" id="loadLayer">
			<div class="statemodal-contain">
				<div class="statemodal-content">
					<div class="statemodal-icon">
						<i class="" id="loadicon"></i>
					</div>
					<div class="statemodal-text" >
						<span id="loadContext">数据加载中…</span>
					</div>
				</div>
			</div>
		</div>
		
		<div id="taskdiv"></div>
		
		<!-- putforward modal -->
		<div class="infor-modal" id="inforModal">
			<div class="infor-inner">
				<div class="infor-contain">
					<div class="informodal-title">
						<div class="modal-title">
							<span>试玩助手</span>
						</div>
					</div>
					<div class="inforModal-content">
						<span id="inforContextTitle"></span>
						<span id="inforContext"></span>
					</div>
				</div>
			</div>
		</div>
		
		<script src="./js/sendtask.js?v=1033"></script>
		<script type="text/javascript" src="./js/lib/map/maps.js"></script>
		<script src="./js/lib/mui/mui.min.js"></script>
		
		<script src="./js/lib/iscroll/iscroll.js"></script>
		<script type="text/javascript">
			
			var urlip = localStorage.getItem('urlip');
			var url = 'http://'+ urlip +':8080/platform-web/';
			
			var pageIndex = '1';
			var myScroll = null;
			var pageTotal = null;
			
			//init 
			loadListData(url,pageIndex);
			
			//after loaded scroll
			myScroll = new IScroll('.taskpage-platform-list',{
				click: true,
				taps:true,
			});
			
			myScroll.on('scrollEnd',function(){
				
				if (this.maxScrollY == this.y) {
					if( pageIndex < pageTotal){
						pageIndex++;
												
						$('#loadicon').removeAttr('class').addClass('loadicon')
						$('#loadLayer').show();
						$('#loadContext').text('页面加载中...');
						
						setTimeout(function(){
							$('#loadLayer').hide();
						},1500)
						
						//加载列表
						loadListData(url,pageIndex);
					}else{
						if( !( $('#platformInfor').children('div').hasClass('loadover') ) ){
							$('#platformInfor').append('<div class="loadover"><span>没有更多数据了...</span></div>')
						}
					}
				}
			});
			
			function loadListData(url,pageIndex){
				$.ajax({
					type: "POST",
					url:url+'platform/platformList',
					dataType: "json",
					data:{
						pageNum:pageIndex, //当前页
						pageDataCount:10 //每页的数据条数
					},
					success: function(data){
						
						if(data.code === 403){
							location.href = './login.html'
						}else if(data.code === 404){
							alert('设备被锁')
						}else if(data.code == 5000 ){
							pageTotal = data.pages;
							if(data.pageList.length !== 0){
								var platformListHtml = '';
								for(var i=0;i<data.pageList.length;i++){
									platformListHtml += '<div class="platform-item" data-listId="'+ data.pageList[i].id +'"><div class="platform-img">'+
														'<img src="'+ data.pageList[i].image +'" alt="">'+
														'</div><div class="platform-infor"><div class="platform-title">'+
														'<span>'+ data.pageList[i].title +'</span>'+
														'</div><div class="platform-descript">'+
														'<p>'+ data.pageList[i].introduce +'</p>'+
														'</div></div></div>'
								}
								$('#platformInfor').append(platformListHtml);
								myScroll.refresh();
							}else{
								myScroll.destroy();
								$('#platformInfor').html('<div class="platform-empty"><img src="./img/icons/no-record.png" alt=""><span>暂无数据</span></div>');
							}
						}
					}
				});
			}
			
			// H5 plus事件处理 返回上一层
			function plusReady(){
				// Android处理返回键
				plus.key.addEventListener('backbutton',function(){
					console.log(1111)
					location.href = "./index.html";
				},false);
				
			}
			
			if(window.plus){
				plusReady();
			}else{
				document.addEventListener('plusready',plusReady,false);
			}
			
			
		</script>
	</body>

</html>
